﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Economo.WinClient.Controls
{
    public class LoadImage 
    {
        private System.Windows.Forms.OpenFileDialog _fileDialog;
        private string _selectedFileName;
        public LoadImage()
        {
            
        }
        public void OpenImageFile()
        {
            _fileDialog = new OpenFileDialog();
            _fileDialog.Filter = "Images| *.png;*.jpg;*.gif | All files|*.*";
            _fileDialog.DefaultExt = "*.png;*.jpg;*.gif" ;
            DialogResult result = _fileDialog.ShowDialog();
            if (result == DialogResult.OK)
                _selectedFileName = _fileDialog.FileName;
            else
                _selectedFileName = "";
        }
        public byte[] GetFileBinary
        {            
            get
            {                
                if (_selectedFileName!="" && File.Exists(_selectedFileName))
                {
                    return File.ReadAllBytes(_selectedFileName);                    
                }
                else
                    return null;
            }
        }
    

    }
}
